import java.util.Scanner;

public class NGuessNumber {

    //生成四个数字
    public int[] generateAnswer(){

        int a,b,c,d;
        int [] e = new int []{};
        for (;;){
            a=(int)(Math.random()*10);
            b=(int)(Math.random()*10);
            c=(int)(Math.random()*10);
            d=(int)(Math.random()*10);
            if (a!=b&&a!=c&&a!=d&&b!=c&&b!=d){
                e = new int[]{a,b,c,d};
                break ;
            }
        }
        return e;
    }

    //接收四个数字
    public int[] getPlayerInput(){
        int f[]= new int[]{};
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数");
        int one =scanner.nextInt();
        System.out.println("请输入第二个数");
        int two = scanner.nextInt();
        System.out.println("请输入第三个数");
        int three = scanner.nextInt();
        System.out.println("请输入第四个数");
        int four = scanner.nextInt();
        f = new int []{one,two,three,four};
        return f;
    }

    //判断对错
    public int iswin( int e [], int f []){
        int A = 0;
        for (int i = 0; i < e.length-1; i++) {
            for (int j = f.length-1; j >= 0; j--) {
                if (e[i]==f[j]){
                    A++;
                }
            }
        }
        return A;
    }

    //比较数字
    public boolean compareGuessAnswer(){
        int e [] = generateAnswer();
        while (true){
            for (;;) {
                int f[] = getPlayerInput();
                for (int i = 0; i < e.length - 1; i++) {
                    for (int j = f.length - 1; j >= 0; j--)
                        if (e[i] == f[j]) {
                            System.out.println("您输入的：" + f[j] + "是正确的");
                        }
                }
                int A = iswin(e, f);
                if (A == 4) {
                    System.out.println("true");
                    break;
                } else {
                    System.out.println("false");
                }
            }
        }
    }

    public static void main(String[] args) {
        NGuessNumber nGuessNumber = new NGuessNumber();
        nGuessNumber.compareGuessAnswer();

    }
}